package com.eshop.product.mapper;

import com.eshop.product.model.ProductProperty;
import org.apache.ibatis.annotations.*;

/**
 * @ClassName CategoryMapper
 * @Description
 * @Author 47980
 * @Date 2020/5/17 16:08
 * @Version V_1.0
 **/
@Mapper
public interface ProductPropertyMapper {

    @Insert("INSERT INTO product_property(name,value,product_id) VALUES(#{name},#{value},#{productId})")
    public void add(ProductProperty productProperty);

    @Update("UPDATE product_property SET name=#{name},value=#{value},product_id=#{productId} WHERE id=#{id}")
    public void update(ProductProperty productProperty);

    @Delete("DELETE FROM product_property WHERE id=#{id}")
    public void delete(Long id);

    @Select("SELECT * FROM product_property where id=#{id}")
    @Results({
        @Result(column = "product_id", property = "productId")
    })
    public ProductProperty findById(Long id);

    @Select("SELECT * FROM product_property where product_id=#{productId}")
    @Results({
            @Result(column = "product_id", property = "productId")
    })
    public ProductProperty findByProductId(Long productId);
}
